import { h } from 'vue';

import { Checkbox } from 'ant-design-vue';

/** 分配文件分类授权列表的字段 */
export function useAssignFileCategoriesGridColumns() {
  return [
    {
      type: 'checkbox',
      fixed: 'left',
      align: 'left',
      width: 40,
    },
    {
      field: 'id',
      title: '授权分类id',
      align: 'left',
      fixed: 'left',
      visible: false,
      minWidth: 100,
    },
    {
      field: 'name',
      title: '分类名称',
      align: 'left',
      fixed: 'left',
      treeNode: true,
      minWidth: 200,
    },
    {
      field: 'readEnabled',
      title: '可读',
      width: 100,
      align: 'center',
      slots: {
        default: ({ row }) =>
          h(Checkbox, {
            checked: row.readEnabled,
            'onUpdate:checked': (val: boolean) => (row.readEnabled = val),
          }),
      },
    },
    {
      field: 'writeEnabled',
      title: '可写',
      width: 100,
      align: 'center',
      slots: {
        default: ({ row }) =>
          h(Checkbox, {
            checked: row.writeEnabled,
            'onUpdate:checked': (val: boolean) => (row.writeEnabled = val),
          }),
      },
    },
    {
      title: '分类编码',
      field: 'code',
      minWidth: 200,
    },
    {
      title: '存放基础路径',
      field: 'basePath',
      minWidth: 200,
    },
    {
      title: '配置名称',
      field: 'configName',
      minWidth: 200,
    },
  ];
}
